<?php
if(isset($include) && $include) {
?>
<?php
require_once('classes/login.class.php');
$login = Login::getInstance();
$login->init("users");

$error = "";
if(isset($_POST[login])) {
	if($_POST[username]=="")
		$error .= "je gebruikersnaam is leeg<br />";
	if($_POST[password]=="")
		$error .= "je wachtwoord is leeg";
	if($error=="") {
			$login->loginByUsername($_POST[user],$_POST[pass]);
		if($login->isLogin()==false)
			$error .= "login failed";
	}
} else if(isset($_POST[hash])) {
	if($_POST[personalcode]=="" && $_POST[personalcode2]=="" )
		$error .= "de hash is leeg<br />";
	if($error=="") {
		if($_POST[personalcode2]!="")
			$hashcode = $_POST[personalcode2];
		else
			$hashcode = $_POST[personalcode];
			$login->loginByHash($hashcode);
		if($login->isLogin()==false)
			$error .= "login failed";
	}
}

if($login->isLogin()==true)
	header("location: index.php");
else {
	echo "<p>".$error."</p>";
}

?>

<?php
}
?>